<template>
  <div id="top-nav">
        <van-icon @click="toBack" class="history" name="arrow-left" />
        <div class="title">{{title}}</div>
        <span class="nav-right">
            <slot name="right"></slot>
        </span>
  </div>
</template>

<script>
// UI组件
import Vue from 'vue'
import { Icon } from 'vant'

// 自定义方法
import { backHistory } from '_projectFn/page'

Vue.use(Icon)
export default {
    props: {
        title: {
            type: String,
            default: '工品业务 — 业务互助社群平台'
        }
    },
    methods: {
        toBack() {
            backHistory()
        }
    }
}
</script>

<style lang="scss" scoped>
    #top-nav {
        background: #333333;
        height: 40px;
        width: 100%;
        color: white;
        font-size: 16px;
        z-index: 1;
        position: sticky;
        top: 0;
        display: flex;
        text-align: center;

        .history {
            display: inline-block;
            height: 100%;
            line-height: 40px;
            width: 40px;
            color: white;
            font-size: 14px;
            font-weight: bold;
        }

        .title {
            width: 100%;
            height: 100%;
            line-height: 40px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            // padding-right: 40px;
        }

        .nav-right {
            flex-shrink: 0;
            height: 100%;
            min-width: 40px;
            line-height: 40px;
            max-width: 100px;
        }
    }
</style>